<?php
// +----------------------------------------------------------------------
// | Author: 
// +----------------------------------------------------------------------

namespace app\wechat\controller;
use think\Controller;
/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class RedirectsController extends Controller {
    /**
     * 封面
     */
    public function main(){
        $account_id = input('account_id');
        $wxAccount = db('WxAccount')->where(['id'=>$account_id])->find();
        if(!$wxAccount){
            $this->error('未知错误，请联系管理员');
            exit();
        }
        $redictUrl = 'http://e-cigarette.huan-ju.cn/'.Url('StoreAdmin/index');

        $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid='.$wxAccount['appid'].'&redirect_uri='.urlencode($redictUrl).'&response_type=code&scope=snsapi_base&state=123#wechat_redir';
        
        $this->assign([
            'redirectUrl' => $url
        ]);
        return $this->fetch('main');
    }
}